<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/26
 * Time: 17:11
 */
$access_token="9_KZeDoNV5aDa5EGda5DoC1aVHaZHDvsV5aSFEX0gdD_kIxJE69xHsjn70QlHP-d1gt4rb4wiWrnmy-fDv5CR4CVEXCmdjsAvZrbO7XWf5pFb-s9gGq-9UvtLOP9lLhm9TwxIyk6hy8kP_FQg6VTAeAGAAYF";
define('ACCESS_TOKEN',$access_token);
$url="https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".ACCESS_TOKEN;
//创建curl句柄
$ch=curl_init();
//设置curl
curl_setopt($ch,CURLOPT_URL,$url);
//捕获内容但不输出
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
//模拟发送post
curl_setopt($ch,CURLOPT_POST,1);
//发送相关数据
$data=' {
     \"button\":[
     {    
          \"type\":\"click\",
          \"name\":\"今日歌曲\",
          \"key\":\"V1001_TODAY_MUSIC\"
      },
      {
           \"name\":\"菜单\",
           \"sub_button\":[
           {    
               \"type\":\"view\",
               \"name\":\"搜索\",
               \"url\":\"http://www.soso.com/\"
            },
            {
                 \"type\":\"miniprogram\",
                 \"name\":\"wxa\",
                 \"url\":\"http://mp.weixin.qq.com\",
                 \"appid\":\"wx286b93c14bbf93aa\",
                 \"pagepath\":\"pages/lunar/index\"
             },
            {
               \"type\":\"click\",
               \"name\":\"赞一下我们\",
               \"key\":\"V1001_GOOD\"
            }]
       }]
 }';
//发送时传递数据
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
//禁止服务器端校验ssl
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
//执行curl
$output=curl_exec($ch);
if($output==false){
    echo curl_error($ch);
}else{
    echo $output;
}
//关闭curl();
curl_close($ch);